package day01
/**
 *  打印语法如下:
 *    printf("%d岁的%s在张家界学院学习", age, name )
 *    println(age + " 岁的" + name + "张家界学院学习")
 *    println(s"${age}岁的 ${name} 在张家界学院学习")
 *    println(f"The num is ${num}%2.4f")
 *    println(raw"The name is ${name}")
 */
object OutputDemo {
  def main(args: Array[String]): Unit = {

    val name: String = "alice"
    val age: Int = 18

    val sql =s"""
         |select
         |  *
         |from
         |   student
         |where
         |   name = ${name}
         |and
         |   age > ${age}
         |""".stripMargin

         // println("我的 sql为: " + sql )
         // println(raw"我的sql为: ${sql}")
         println(s"我的sql为: ${sql}")
  }


  private def TestPrintln(): Unit = {
    val name: String = "alice"
    val age: Int = 18
    println(age + " 岁的" + name + "张家界学院学习")

  }

  def printDemo(): Unit = {
    val name: String = "alice"
    val age: Int = 18
    printf("%d岁的%s在张家界学院学习", age, name) // 18岁的alice在张家界学院学习
    println()
    println(s"${age}岁的 ${name} 在张家界学院学习") // 18岁的 alice 在张家界学院学习

    val num: Double = 2.3456
    printf("%2.4f岁的%s在张家界学院学习", num, name) // 2.3456岁的alice在张家界学院学习
    println()
    println(f"The num is ${num}%2.4f") // The num is 2.3456

    println("===================================>")
    // 字符串格式化 命令
    println(raw"The name is ${name}") // The name is alice
    println(raw"The num is ${num}") // The num is 2.3456
  }

}
